<template>
	<div class="main">
				<!-- 登录弹窗 -->
		<div v-if="showLogin">
	  		<LoginWindow @changeShow = "getModel(arguments)"></LoginWindow>
	  	</div>
		<div class="top">
			<div class="info">
				<div class="info1"></div>
				<div class="info2"></div>
				<div class="info3"></div>
				<div class="head">
					<open-data type="userAvatarUrl"></open-data>
				</div>
				<div class="info3"></div>
				<div class="info2"></div>
				<div class="info1_1"></div>
			</div>
			<div class="name">
				<open-data type="userNickName"></open-data>
			</div>
		</div>

		<div class="no"></div>
		<div class="list">
			<div class="item" @click="toOrder">
				<image class="item_img" src="/static/images/me3.png"></image>
				<div class="item_text">我的订单</div>
				<div class="item_go">查看 ＞</div>
			</div>
			<div class="item" @click="toCollect">
				<image class="item_img" src="/static/images/me1.png"></image>
				<div class="item_text">我的收藏</div>
				<div class="item_go">管理 ＞</div>
			</div>
			<div class="item" @click="toAdress">
				<image class="item_img" src="/static/images/me2.png"></image>
				<div class="item_text">地址管理</div>
				<div class="item_go">管理 ＞</div>
			</div>
		</div>
	</div>
</template>
<script type="text/javascript">
import LoginWindow from '@/components/LoginWindow'
export default {
	components: {
	    LoginWindow
	 },
	data(){
		return{
			showLogin: false, //控制登录弹窗
			userinfo:'',
		}
	},
	mounted(){
		const userinfo = wx.getStorageSync('userinfo')
	    if (userinfo.openId) {
	    } else {
	      	wx.hideTabBar()
	      	this.showLogin = true
	    }
	},
	methods:{
		toOrder(){
			const userinfo = wx.getStorageSync('userinfo')
			if (userinfo.openId) {
				wx.navigateTo({
		        	url: '/pages/myOrder/main'
		     	})
		    } else {
		      	wx.hideTabBar()
		      	this.showLogin = true
		    }
		},
		toCollect(){
			const userinfo = wx.getStorageSync('userinfo')
			if (userinfo.openId) {
				wx.navigateTo({
		        	url: '/pages/collect/main'
		     	})
		    } else {
		      	wx.hideTabBar()
		      	this.showLogin = true
		    }
		},
		toAdress(){
			const userinfo = wx.getStorageSync('userinfo')
			if (userinfo.openId) {
				wx.navigateTo({
		        	url: '/pages/addressSelect/main'
		     	})
		    } else {
		      	wx.hideTabBar()
		      	this.showLogin = true
		    }
		},
		//与弹窗间的通信
	  	getModel (val) {
	      	this.showLogin = val[0]
	    },
	}
}
</script>

<style lang='scss'>
	@import "./style.scss";
</style>


